package com.yidu.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yidu.comment.Page;
import com.yidu.comment.Tools;
import com.yidu.dao.SnFirmMapper;
import com.yidu.model.SnFirm;
import com.yidu.service.SnFirmService;
/**
 * 供应商实现类
 * @author ChenYingZhu
 * @date 2018年11月30日 下午10:26:08
 */
@Service
public class SnFirmServiceImpl implements SnFirmService{
	/**
	   * 注入供应商mapper
	 */
	@Resource
	SnFirmMapper firmMapper;
	/**
	   * 查询所有
	 */
	@Override
	public List<SnFirm> query(Map<String, Object>  map) {
		 List<SnFirm> list = firmMapper.query(map);
		 return list;
	}
	/**
	   * 查询行数
	 */
	@Override
	public int selectcount(Map<String, Object>  map) {
		return firmMapper.selectcount(map);
	}
	/**
	   * 增加或修改
	 */
	@Override
	public int addOrUpdate(SnFirm snFirm) {
		snFirm.setOptimr(Tools.getCurDateTime());
		int row = 0;
		if(snFirm.getFirmId() != null && !"".equals(snFirm.getFirmId())){
			row = firmMapper.updateByPrimaryKeySelective(snFirm);
		}else{
			row = firmMapper.insertSelective(snFirm);
		}
		return row;
	}
	/**
	   * 根据ID查询
	 */
	@Override
	public SnFirm selectByPrimaryKey(String firmId) {
		return  firmMapper.selectByPrimaryKey(firmId);
	}
	/**
	   * 删除修改为不可用
	 */
	@Override
	public int updateByPrimaryKeySelective(SnFirm snFirm) {
		return firmMapper.updateByPrimaryKeySelective(snFirm);
	}

	 
}
